module two {
	export class Login2Page extends BaseComponent {
		public constructor() {
			super("Login2Page");
		}

		public btn_start: eui.Button;
		public bg: eui.Image;

		p1: egret.tween.TweenGroup;
		protected created(): void {
			super.created();

			two.addTap(this.btn_start, () => {
				this.btn_start.enabled = false;
				if (this.btn_start.alpha == 1) {

					User_getMyJewelryProxy.getInstance().send({
					}, ()=> {
						two.changePage("map");
					})
				}
			});
		}

		private onShowTips(quick: boolean): void {
			if (quick) {
				let cnt = 0;
				let bgs = ['p2_bg1_png', 'p2_bg2_png', 'p2_bg3_png']
				this.timeId = egret.setInterval(() => {
					cnt++;
					cnt = cnt % bgs.length;
					this.bg.source = bgs[cnt]
				}, this, 5000);
			}
			else {
				this.p1.play();
				this.p1.once(egret.Event.COMPLETE, () => {
					let cnt = 0;
					let bgs = ['p2_bg1_png', 'p2_bg2_png', 'p2_bg3_png']
					this.timeId = egret.setInterval(() => {
						cnt++;
						cnt = cnt % bgs.length;
						this.bg.source = bgs[cnt]
					}, this, 5000);
				}, this);
			}
		}

		private timeId = -1;
		protected removed(): void {
			super.removed();

			egret.clearInterval(this.timeId);
		}

		// public gp_tips: eui.Group;
		private showTips(): void {
			// for (let i = 0; i < this.gp_tips.numChildren; i++) {
			// 	this.gp_tips.getChildAt(i).alpha = 0;
			// 	let t = egret.Tween.get(this.gp_tips.getChildAt(i)).wait(i * 800).to({ alpha: 1 }, 1000).wait(400);

			// 	if (i == this.gp_tips.numChildren - 1) {
			// 		t.call(() => {
			// 			this.btn_start.visible = true;
			// 		})
			// 	}
			// }
		}

		private showIme(): void {
			// for (let i = 0; i < this.gp_tips.numChildren; i++) {
			// 	this.gp_tips.getChildAt(i).alpha = 1;
			// 	egret.Tween.removeTweens(this.gp_tips.getChildAt(i));
			// }
		}

		refreshData(type: string, data: any): void {
			super.refreshData(type, data);

			switch (type) {
				case "onInitData":
					let quick = data.quick;
					this.onShowTips(quick == 1);
					break;
			}
		}
	}

	two.setClassMap("login2", "two.Login2Page");
}